import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
// ElementPlus按需导入
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
//end ElementPlus按需导入

// 给script 标签加name
import setUpname from 'vite-plugin-vue-setup-extend'

// https://vite.dev/config/
export default defineConfig({
  base: '/',
  plugins: [
    vue(),
    setUpname(),
    vueDevTools(),
    // ElementPlus按需配置
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    })
    //end ElementPlus按需配置
  ],
  server: {
    host: '0.0.0.0',
    port: 8000,
    allowedHosts: [
      'cms.jjbnm.top'
    ]
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
})
